﻿<?php
$this->headScript()->appendFile($this->publicUrl . "Scripts/jquery.js");
$this->headScript()->appendFile($this->publicUrl . "Scripts/formsValidation.js");
$this->headScript()->appendFile($this->publicUrl . "Scripts/selectSkin.js"); 
?>
<?php $this->headScript()->captureStart(); ?>
function validateSettingsForm() {
	var validator = new FormValidator('settings');
	
	validator.isNotEmpty('username', '<?= $this->translate('isEmpty') ?>');
	validator.isNotShorterThan('username', 
		"<?= $this->validationMessage('stringLengthTooShort', '3') ?>", 3);
	validator.isNotLongerThan('username', 
		"<?= $this->validationMessage('stringLengthTooLong', '50') ?>", 50);	
	
	validator.isNotEmpty('email', '<?= $this->translate('isEmpty') ?>');		
	validator.isEmail('email',
		"<?= $this->validationMessage('emailAddressInvalid') ?>");
		
	validator.isNotEmpty('fullName', '<?= $this->translate('isEmpty') ?>');
	validator.isNotEmpty('address', '<?= $this->translate('isEmpty') ?>');

	return validator.result;
}

setupSelectSkin("<?= $this->url(array('action' => 'skins-ajax-request', 'controller' => 'user')) ?>");
<?php $this->headScript()->captureEnd(); ?>

<h2><?= $this->translate('Settings') ?></h2>

<?php $this->form->setAttrib('onsubmit', 'return validateSettingsForm();') ?>
<?= $this->form ?>

<div id="loading"></div>